package me.imvc.generate.template;

import java.util.*;

public class ViewEditNewTemplate
{
  protected static String nl;
  public static synchronized ViewEditNewTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    ViewEditNewTemplate result = new ViewEditNewTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%>" + NL + "<%@taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%>" + NL + "<div class=\"pageContent\">" + NL + "\t<form method=\"post\" action=\"${webUrl}/";
  protected final String TEXT_2 = "\"" + NL + "\t\tclass=\"pageForm required-validate\"" + NL + "\t\tonsubmit=\"return validateCallback(this, dialogAjaxDone);\">" + NL + "\t\t<div class=\"pageFormContent\" layoutH=\"56\">" + NL + "\t\t\t<div class=\"unit\">" + NL + "\t\t\t";
  protected final String TEXT_3 = NL + "\t\t\t\t<p>" + NL + "\t\t\t\t\t<label>";
  protected final String TEXT_4 = "：</label>" + NL + "\t\t\t\t\t<input name=\"";
  protected final String TEXT_5 = ".";
  protected final String TEXT_6 = ".";
  protected final String TEXT_7 = "\" type=\"text\" size=\"30\" " + NL + "\t\t\t\t\t\tvalue=\"\" alt=\"请输入";
  protected final String TEXT_8 = "\" />" + NL + "\t\t\t\t</p>" + NL + "\t\t\t";
  protected final String TEXT_9 = NL + "\t\t\t</div>" + NL + "\t\t</div>" + NL + "\t\t<div class=\"formBar\">" + NL + "\t\t\t<ul>" + NL + "\t\t\t\t<li>" + NL + "\t\t\t\t   <div class=\"buttonActive\"><div class=\"buttonContent\"><button type=\"submit\">保存</button></div></div>" + NL + "\t\t\t\t</li>" + NL + "\t\t\t\t<li>" + NL + "\t\t\t\t   <div class=\"button\"><div class=\"buttonContent\"><button type=\"button\" class=\"close\">取消</button></div></div>" + NL + "\t\t\t\t</li>" + NL + "\t\t\t</ul>" + NL + "\t\t</div>" + NL + "\t</form>" + NL + "</div>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
Map<String,Object> dataMap=(Map<String,Object>) argument;
LinkedHashMap<String, String> entityAttributMap=(LinkedHashMap<String, String>)dataMap.get("entityAttributMap");
String entityClass=dataMap.get("entityClass").toString();
String entityName=dataMap.get("entityName").toString();
String EntityName=me.imvc.lib.StringTools.firstToUpperCase(entityName);
String modelClass=dataMap.get("modelClass").toString();
String modelName=dataMap.get("modelName").toString();
String ModelName=me.imvc.lib.StringTools.firstToUpperCase(modelName);
String controllerPackage=dataMap.get("controllerPackage").toString();
String controllerClass=dataMap.get("controllerClass").toString();
String viewUrl=dataMap.get("viewUrl").toString();
String view=dataMap.get("view").toString();

    stringBuffer.append(TEXT_1);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_2);
    for (String key : entityAttributMap.keySet()){
    stringBuffer.append(TEXT_3);
    stringBuffer.append(entityAttributMap.get(key));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(entityName);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(key);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(entityAttributMap.get(key));
    stringBuffer.append(TEXT_8);
    }
    stringBuffer.append(TEXT_9);
    return stringBuffer.toString();
  }
}
